package com.ning.parking.domain.dto;

import cn.hutool.core.date.DatePattern;
import com.alibaba.fastjson.annotation.JSONField;

import com.ning.parking.config.CmdTypeEnum;
import com.ning.parking.config.WebSocketServer;
import lombok.*;

import javax.websocket.Session;
import java.util.Date;

/**
 * @author pengcan
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class Message {

    /**
     * 发送者 form
     */
    private String from;

    /**
     * 命令指令
     */
    private CmdTypeEnum cmdType;

    /**
     * 发送的文本
     */
    private Object body;

    /**
     * -1 是广播
     * 其余是个人
     */
    @Builder.Default
    private String to = WebSocketServer.BROADCAST_MSG_TYPE;

    /**
     * 发送时间
     */
    @JSONField(format = DatePattern.NORM_DATETIME_PATTERN)
    private Date date;

    /**
     * token
     */
    private String accessToken;

    private Session session;

}
